Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Windows.Forms

Public Class FrmCrNXTTongHop_Ngay_nhom
    Private arg As Integer
    Private data As DataTable
    Private thang, nam, kho As String
    Private tiendauky As Double
    Private customerReport As ReportDocument

    Public Sub setArg(ByVal i As Integer)
        arg = i
    End Sub

    Delegate Sub WaitDelegate()

    Private Sub FrmCrNXTTongHop_Ngay_nhom_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
        If arg = 1 Then
            globalVariale.runWaitting = True
            Dim wd As New WaitDelegate(AddressOf moduleWaitting.runningWait)
            wd.BeginInvoke(Nothing, Nothing)
            Dim sqlQuery As String = ""
            sqlQuery = " SELECT t1.*, t3.ma_nhom_hanghoa as ma ,t3.ten_nhom_hanghoa as tennhom "
            sqlQuery += "  FROM ( tbl_dot_NhapXuatTongHop_ngay as t1 left join tbl_hanghoa as t2 on t1.ma_hanghoa=t2.ma_hanghoa )"
            sqlQuery += " left join tbl_nhom_hanghoa as t3 on t2.ma_nhomhanghoa=t3.ma_nhom_hanghoa "
            sqlQuery += "  where  (soluong_dauky<>0 OR soluongnhap_trongky<>0 OR soluongxuat_trongky<>0 OR soluongcuoiky<>0) ORDER BY ten_bietduoc "
            Dim reportPath = Application.StartupPath & "\" & "crNhapXuatTonTongHop_Ngay_nhom.rpt"
            customerReport = New ReportDocument()
            customerReport.Load(reportPath)
            customerReport.SetDataSource(moduleReportConfig.GetDataTable(sqlQuery))
            customerReport.SetParameterValue("month", thang)
            customerReport.SetParameterValue("year", nam)
            customerReport.SetParameterValue("TKho", kho)
            customerReport.SetParameterValue("company", globalVariale.COMPANY)
            customerReport.SetParameterValue("address", globalVariale.ADDRESS)
            Me.CrNXTTongHopview.ReportSource = customerReport
            Me.CrNXTTongHopview.Zoom(80)

            globalVariale.runWaitting = False

        Else
            globalVariale.runWaitting = True
            Dim wd As New WaitDelegate(AddressOf moduleWaitting.runningWait)
            wd.BeginInvoke(Nothing, Nothing)
            Dim sqlQuery As String = ""
            sqlQuery = "SELECT * FROM tbl_dot_NhapXuatTongHop_ketoan_ngay where (soluong_dauky<>0 OR soluongnhap_trongky<>0 OR soluongxuat_trongky<>0 OR soluongcuoiky<>0)ORDER BY ten_bietduoc"
            Dim reportPath = Application.StartupPath & "\" & "crNhapXuatTonTongHop_Ngay_nhom.rpt"
            customerReport = New ReportDocument()
            customerReport.Load(reportPath)
            customerReport.SetDataSource(moduleReportConfig.GetDataTable(sqlQuery))
            customerReport.SetParameterValue("month", thang)
            customerReport.SetParameterValue("year", nam)
            customerReport.SetParameterValue("TKho", kho)
            customerReport.SetParameterValue("company", globalVariale.COMPANY)
            customerReport.SetParameterValue("address", globalVariale.ADDRESS)
            Me.CrNXTTongHopview.ReportSource = customerReport
            Me.CrNXTTongHopview.Zoom(80)

            globalVariale.runWaitting = False
        End If

       
    End Sub

    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub
    Public Sub setThang(ByVal s As String)
        thang = s
    End Sub

    Public Sub setNam(ByVal s As String)
        nam = s
    End Sub
    Public Sub setKho(ByVal s As String)
        kho = s
    End Sub

    Public Sub setData(ByVal d As DataTable)
        data = d
    End Sub


End Class
